package com.wisdomstar.common.enums;

/**
 * @author RinMi
 * @since 2023/6/2
 */
public enum BucketTypeEnum {

    //PDF
    PDF_TYPE("application/pdf", "pdf"),
    //JPEG
    JPEG_TYPE("image/jpeg", "jpeg"),
    //PNG
    PNG_TYPE("image/png", "png"),
    //TXT
    TXT_TYPE("text/plain", "text"),
    //GIF
    GIF_TYPE("image/gif", "gif"),
    //BMP
    BMP_TYPE("image/bmp", "bmp");

    private final String contentType;

    private final String fileType;

    BucketTypeEnum(String contentType, String fileType) {
        this.contentType = contentType;
        this.fileType = fileType;
    }

    public String getContentType(){
        return this.contentType;
    }

    public String getFileType(){
        return this.fileType;
    }

    public static String getFileType(String contentType){
        for (BucketTypeEnum bucketTypeEnum : BucketTypeEnum.values()){
            if (bucketTypeEnum.getContentType().equals(contentType)){
                return bucketTypeEnum.getFileType();
            }
        }
        return null;
    }

    public static String getContentType(String fileType){
        for (BucketTypeEnum bucketTypeEnum : BucketTypeEnum.values()){
            if (bucketTypeEnum.getFileType().equals(fileType)){
                return bucketTypeEnum.getContentType();
            }
        }
        return null;
    }

    public static boolean checkFileType(String fileType){
        for (BucketTypeEnum bucketTypeEnum : BucketTypeEnum.values()){
            if (bucketTypeEnum.getFileType().equals(fileType)){
                return true;
            }
        }
        return false;
    }
}
